package com.example.activemq.consumer;

import com.alibaba.fastjson.JSON;
import com.example.activemq.pojo.MessagePojo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;


/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2021/4/2 22:50
 * @Description TODO
 */
@Component
@Slf4j
public class TopicConsumerListener {


    //接收topic类型消息
    //destination对应配置类中ActiveMQTopic("springboot.topic")设置的名字
    //containerFactory对应配置类中注册JmsListenerContainerFactory的bean名称
    @JmsListener(destination = "${spring.activemq.topic-name}",containerFactory = "jmsTopicListenerContainerFactory")
    public void receive(MessagePojo messagePojo){
      log.info("topic 收到消息 messagePojo:{}",JSON.toJSONString(messagePojo));
    }
}
